package hibernate_advanced_apply.object_relevance_mapping.many_to_one.config;

import hibernate_advanced_apply.object_relevance_mapping.many_to_one.Student;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

/**
 * @author Administrator
 * @create 2019-01-03 9:07
 * @desc 测试多对一单向映射
 **/
public class Test {

    public static void main(String args[]){
        Configuration config=new Configuration();
                config.configure("hibernate_advanced_apply/object_relevance_mapping/many_to_one/config/student_config" +
                        "/mapping.xml");

        SessionFactory factory=config.buildSessionFactory();
        Session session=factory.openSession();
        Transaction tion=session.beginTransaction();
        Student student=session.get(Student.class,1);
        System.out.println(student.getName());
        System.out.println(student.getTeacher().getName());

        tion.commit();
        session.close();



    }
}
